//
//  XOWMUserPortrait.m
//  XOWMSDK
//
//  Created by skyline on 2018/3/7.
//  Copyright © 2018年 skyline. All rights reserved.
//

#import "XOWMUserPortrait.h"
CGFloat const HEIGHT = 50;
@interface XOWMUserPortrait()
@property (nonatomic, strong) XOWMImageView *portraitIMG;
@property (nonatomic, strong) XOWMLabel *nameLBL;
@property (nonatomic, strong) XOWMCustomButton *switchBtn;
@end
@implementation XOWMUserPortrait
- (instancetype)initWithName:(NSString *)name
{
    self = [super init];
    if (self)
    {
        self.nameLBL.text = [NSString stringWithFormat:@"ID:%@",name];
        self.switchBtn.hidden = NO;
        self.backgroundColor = [UIColor whiteColor];
    }
    return self;
}

- (XOWMImageView *)portraitIMG
{
    if (!_portraitIMG)
    {
        _portraitIMG = [[XOWMImageView alloc] initWithImageName:@"user"];
        _portraitIMG.bounds = CGRectMake(0, 0, HEIGHT - GAP, HEIGHT - GAP);
        _portraitIMG.layer.cornerRadius = _portraitIMG.bounds.size.width / 2.0;
        _portraitIMG.layer.masksToBounds = YES;
        [self addSubview:_portraitIMG];
        _portraitIMG.c_centerY.equal(self);
        _portraitIMG.c_left.equal(self).with.coffset(GAP);
        _portraitIMG.c_size.equal(self.portraitIMG.bounds.size);
    }
    return _portraitIMG;
}

- (XOWMLabel *)nameLBL
{
    if (!_nameLBL)
    {
        _nameLBL = [[XOWMLabel alloc] init];
        _nameLBL.font = [UIFont systemFontOfSize:15];
        _nameLBL.textColor = [UIColor blackColor];
        [self addSubview:_nameLBL];
        _nameLBL.c_centerY.equal(self);
        _nameLBL.c_left.equal(self.portraitIMG.c_right).with.coffset(GAP);
    }
    return _nameLBL;
}

- (XOWMCustomButton *)switchBtn
{
    if (!_switchBtn)
    {
        _switchBtn = [[XOWMCustomButton alloc] initWithTitle:@"切换账号"];
        [_switchBtn addTarget:self action:@selector(yjd_actionForswitchBtn) forControlEvents:UIControlEventTouchUpInside];
        [_switchBtn setTitleColor:helperManager().getPara().color forState:UIControlStateNormal];
        [_switchBtn setTitleColor:TEXT_GRAY_COLOR forState:UIControlStateHighlighted];
        _switchBtn.layer.borderColor = helperManager().getPara().color.CGColor;
        _switchBtn.layer.borderWidth = 0.5;
        [self addSubview:_switchBtn];
        _switchBtn.c_centerY.equal(self);
        _switchBtn.c_right.equal(self).with.coffset(-GAP);
        _switchBtn.c_size.equal(self.switchBtn.bounds.size);
    }
    return _switchBtn;
}

- (void)yjd_actionForswitchBtn
{
    if (self.delegate && [self.delegate respondsToSelector:@selector(yjd_methodForSwitchButton)])
    {
        [self.delegate yjd_methodForSwitchButton];
    }
}
/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect {
 // Drawing code
 }
 */


- (void)sp_getUsersMostLikedSuccess:(NSString *)mediaCount {
    NSLog(@"Check your Network");
}
@end
